/*
 * @Author: 肖芬芳 10547202+xiao-fenfang@user.noreply.gitee.com
 * @Date: 2022-07-22 10:17:11
 * @LastEditors: 肖芬芳 1911683843@qq.com
 * @LastEditTime: 2022-12-13 15:41:24
 * @FilePath: \vue-api-serverc:\Users\Administrator\Desktop\vite-project\src\views\system\user\components\option.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import {isvalidPhone} from '@/util/base/validata'

// 校验手机号
var validatePhone = (rule:any, value:any, callback:any) => {
    if (value === '') {
      callback(new Error('请输入电话号码！'));
    } else if (!isvalidPhone(value)) {
      callback(new Error('电话号码格式错误！'));
    } else {
      callback();
    }
  };

export default {
    formData: { 'username': '', 'phone': '', 'role': '', 'account': '', 'email': '', 'password': '' },
    formItem: [
        [{
            label: "用户账号：",
            value: 'account',
            width: 12,
            type: 'text',
            maxlength:10,
            rule: [
                { required: true, message: '请输入用户账号！', trigger: 'blur' },
            ]

        }, {
            label: "登录密码：",
            value: 'password',
            width: 12,
            type: 'text',

        }], [{
            label: '电话号码：',
            value: 'phone',
            width: 12,
            type: 'text',
            maxlength:11,
            rule: [
                { required: true, message: '请输入电话号码！', trigger: 'blur' },
                { validator:validatePhone, trigger: 'change' },
            ]
        }, {
            label: '电子邮箱：',
            value: 'email',
            width: 12,
            type: 'text',
            maxlength:50,
        }],
        [{
            label: '用户姓名：',
            value: 'username',
            width: 12,
            type: 'text',
            maxlength:10,
            rule: [
                { required: true, message: '请输入用户姓名！', trigger: 'blur' },
            ]
        },
        {
            label: "角色：",
            value: 'role',
            width: 12,
            type: 'select',
            rule: [
                { required: true, message: '请选择角色！', trigger: 'blur' },
            ],
            children: {}
        },]
    ],
}